package concurrency

import (
	"fmt"
	atomic "sync/atomic"
)

func main() {
	var num int64
	num = 10
	//原子交换swap ： 直接赋予元素新值，并且返回旧值
	old := atomic.SwapInt64(&num, 20)
	fmt.Println("old =", old)
	fmt.Println("num =", num)
}
